package everydayGrade.t6;

/**
 * @Author: Siantar
 * @Date: 2023-09-02-18:30
 * @Description: 1.0
 */
public class T2511 {
    public int captureForts(int[] forts) {
        int left = -1, right = 0;
        int res = 0;
        while (right < forts.length) {
            if (forts[right] != 0) {
                if (left != -1 && forts[left] + forts[right] == 0) {
                    res = Math.max(res, right - left - 1);
                }
                left = right;
            }
            right++;
        }
        return res;
    }
}
